package com.main.service.handler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.main.service.PersonService;

@Component
public class JpaServiceHandler implements ServiceHandler {
	
	@Autowired
	@Qualifier(value="jpaPersonService")
	PersonService jpaPersonService;
	
	private ServiceHandler nextHandler;
	
	@Override
	public PersonService handleRequest(String persistanceType) {
		if("JPA".equals(persistanceType)) {
			return jpaPersonService;
		} else {
			return nextHandler.handleRequest(persistanceType);
		}
	}

	@Override
	public void setNext(ServiceHandler handler) {
		this.nextHandler = handler;
	}
	
}
